package org.csu.hotelsys.controller;

import org.csu.hotelsys.domain.Room;
import org.csu.hotelsys.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.context.annotation.SessionScope;

import java.util.List;

@Controller
@SessionScope
@RequestMapping("/room/")
@SessionAttributes({"room"})
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping("viewRoom")
    public String viewRoom(String roomType, Model model) {
        List<Room> roomList = roomService.getRoomListbyRoomtype(roomType);
        model.addAttribute("roomList", roomList);

        return "";      //回填返回内容
    }

    //返回到主页面
    @GetMapping("index")
    public String index() {
        return "";          //此处回填主页地址
    }


}
